<template>
    <div class="home">
        <Header />
        <Tab />
        <Button />
        <ActivitySwipe />
        <Hot :jobList="jobList" />
        <div class="outerChain">
            <img src="@/assets/images/outerChain.png" alt="" />
        </div>
        <Company />
        <Search />
    </div>
</template>

<script>
import Header from "@/components/Header.vue";
import Tab from "@/components/Tab.vue";
import Button from "@/components/Button.vue";
import ActivitySwipe from "@/components/ActivitySwipe";
import Hot from "@/components/Hot";
import Company from "@/components/Company";
import Search from "@/components/Search";
import axios from "@/api/axios.js";
import { mapMutations } from "vuex";
export default {
    name: "Home",
    components: {
        Header,
        Tab,
        Button,
        ActivitySwipe,
        Hot,
        Company,
        Search,
    },
    data() {
        return {
            jobList: [],
            wxOpenId:'',
            wxTypw:'',
            wxAuthId:''
        };
    },
    methods: {
        ...mapMutations(["setOpenidData"]),
        getjobList() {
            axios.get("/hkrc/unit/getJobList").then((res) => {
                // console.log(res.data);
                if (res.data.success) {
                    this.jobList = res.data.jobList;
                } else {
                    Toast.fail("出错了");
                }
            });
        },
        getQueryVariable(wxOpenId,wxTypw,wxAuthId) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            vars.forEach((item,index,arr)=>{
                let pair = item.split('=')
                if (pair[0] == wxOpenId) {
                    this.wxOpenId = pair[1];
                    this.setOpenidData(this.wxOpenId)
                }else if(pair[0] == wxTypw){
                    this.wxTypw = pair[1];
                }else if(pair[0] == wxAuthId){
                    this.wxAuthId = pair[1];
                }else{
                    console.log('没有');
                }
            })
            console.log(this.wxOpenId);
            console.log(this.wxTypw);
            console.log(this.wxAuthId);
        },
    },
    created() {
        // 隐藏删除按钮
        this.$store.state.isDel = false;
        // 隐藏搜索结果
        this.$store.state.isSearchDetail = false;
        // 显示搜索标题
        this.$store.state.isHot = true;
        // 隐藏搜索弹框
        this.$store.state.isSearch = false;
        //获取职位列表
        this.getjobList();
        this.getQueryVariable("wxOpenId", "wxTypw", "wxAuthId");
    },
};
</script>
<style lang="less" scoped>
.home {
    background: #f5f6f8;
    .outerChain {
        padding: 15px 18.5px;
        img {
            width: 100%;
            height: 100%;
        }
    }
}
</style>
